package www.sharetime.weshare.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.ArrayList;

import www.sharetime.weshare.R;
import www.sharetime.weshare.utils.L;

/**
 * File Description  : 品种adapter
 *
 * @author : zhanggeng
 * @version : v1.0
 *          **************修订历史*************
 * @email : zhanggengdyx@gmail.com
 * @date : 2017/9/23 14:32
 */

public class BrandAdapter extends RecyclerView.Adapter<BrandAdapter.ViewHolder> {

    public ArrayList<String> getBrandList() {
        return brandList;
    }

    public void setBrandList(ArrayList<String> brandList) {
        this.brandList = brandList;
    }

    ArrayList<String> brandList;
    Context context;

    public BrandAdapter(ArrayList<String> citys, Context context) {
        this.brandList = citys;
        this.context = context;
    }

    public void  notifyDataChange(ArrayList<String> list){
        setBrandList(list);
        notifyDataSetChanged();
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHolder(LayoutInflater.from(context).inflate(R.layout.item_search_tag, parent, false));
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        L.et("type", brandList.get(position));
        holder.mTextView.setText(brandList.get(position));
    }

    @Override
    public int getItemCount() {
        return brandList.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        public View view;
        public TextView mTextView;

        public ViewHolder(View v) {
            super(v);
            mTextView = (TextView) v.findViewById(R.id.tv_search_name);
        }
    }
}
